home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / Dopus Opus II 2.05E.adf / AREXX / arexxdemo.dopus
Text File  |  2004-10-06  |  19KB  |  536 lines

  1. /**************************************************************************/
  2. /*                                                                        */
  3. /* This Arexx script is a simple demo script to show some of the features */
  4. /* offered by the ARexx port in Directory Opus II.                        */
  5. /*                                                                        */
  6. /* Michael Portmann                                                       */
  7. /* V1.0 27th November 1990                                                */
  8. /*                                                                        */
  9. /* Cleaned up a bit by Jonathan Potter, April 25th 1991                   */
  10. /*                                                                        */
  11. /* Thanks to DIABOLIKA GROUP and NEMESIS for this arexx-demo !!!          */
  12. /*                                                                        */
  13. /* To run this script you can either:                                     */
  14. /*                                                                        */
  15. /*    1) Use rx to run the script from the cli                            */
  16. /*    2) Create a custom gadget for this script                           */
  17. /*    3) Click on the ARexx gadget and type in the path and name of this  */
  18. /*       script, for example rexx:DOpus/Demo.DOpus                        */
  19. /* or 4) Call this ARexx script from another program which will allow     */
  20. /*       you to run ARexx scripts                                         */
  21. /*                                                                        */
  22. /*     Please check your DOpus manual or the other programs manual if you */
  23. /*  do not understand how to do the above.                                */
  24. /*                                                                        */
  25. /**************************************************************************/
  26.  
  27. address 'dopus_rexx'
  28.  
  29. options results
  30.  
  31. signal on error         /* On signal ERROR, exit script */
  32. signal on syntax        /* On signal SYNTAX, exit script */
  33. signal on ioerr         /* On signal IOERR, exit script */
  34.  
  35. clear_top = 'A0'X
  36.  
  37. /******************************************************/
  38. /*                                                    */
  39. /*               Start main part of demo              */
  40. /*                                                    */
  41. /******************************************************/
  42.  
  43. dopustofront
  44. toptext clear_top
  45.  
  46. /************************************************************
  47. ************************************************************/
  48. address 'dopus_rexx'
  49.  
  50. options results
  51.  
  52. signal on error         /* On signal ERROR, exit script */
  53. signal on syntax        /* On signal SYNTAX, exit script */
  54. signal on ioerr         /* On signal IOERR, exit script */
  55.  
  56. clear_top = 'A0'X
  57.  
  58. dopustofront
  59. toptext clear_top
  60.  
  61. /***********************************************************
  62. ************************************************************/
  63.  
  64. status 71                   /* Is Directory Opus currently iconified ? */
  65. icon = result
  66. if icon = 1 then uniconify  /* Uniconify if already iconified */
  67. 'status 47 0 set SYS:diabolika'      /* Read DF0: into the left hand window */
  68. 'status 47 1 set SYS:diabolika'      /* Read RAM: into the right hand window */
  69. if icon = 1 then iconify    /* If iconified before, return to that state */
  70.  
  71. /**********************************************************
  72. ***********************************************************/
  73.  
  74.  call demo_intro
  75.  
  76.  call flash 3,'*** Back to front - part 1 ***'
  77.  call back_front
  78.  call display '*** End back to front part ***',4,4
  79.  
  80.  call flash 3,'*** Requesters - part 2 ***'
  81.  call requester_demo
  82.  call display '*** End requester part ***',4,4
  83.  
  84.  call flash 3,'*** Busy pointer - part 3 ***'
  85.  call busy_demo
  86.  call display '*** End busy pointer part ***',4,4
  87.  
  88.  call flash 3,'*** File adding/removing - part 4 ***'
  89.  call file_demo
  90.  call display '*** End file adding/removing part ***',4,4
  91.  
  92.  call flash 3,'*** Configuration settings - part 5 (the last) ***'
  93.  call config_demo
  94.  call display '*** End configuration settings ***',4,4
  95.  
  96.  call display '*** End of Directory Opus arexx-demo ! ***',4,2
  97.  call display 'Thankyou, enjoy your script writing!',4,2
  98.  
  99. return
  100.  
  101. /******************************************************/
  102. /*                                                    */
  103. /*            Display start of intro to demo          */
  104. /*                                                    */
  105. /* (Pretty simple, uses the flash and wait functions  */
  106. /*  at the end of this script)                        */
  107. /*                                                    */
  108. /******************************************************/
  109.  
  110. demo_intro:
  111.  call flash 5,'*** NEMESIS BBS ***'
  112.  
  113.  call wait(2)
  114.  
  115.  call display 'Sysop URAN CoSysop REJ',2,1
  116.  call display 'presents:',2,3
  117.  call display 'Directory Opus II Ver. 2.05e 100%',5,0
  118.  call display 'Please wait until arexx-demo has finished',3,4
  119. return
  120.  
  121. /******************************************************/
  122. /*                                                    */
  123. /*               Change requester gadgets             */
  124. /*                                                    */
  125. /*  This function shows how to request a boolean      */
  126. /* result through DOpus and how to change the gadget  */
  127. /* text to customize the requester.                   */
  128. /*                                                    */
  129. /******************************************************/
  130.  
  131. requester_demo:
  132.  status 69 set 'URAN'
  133.  status 70 set 'REJ'
  134.  
  135.  call display 'I can use a boolean requester for input',4,1
  136.  
  137.  request 'Click on' URAN 'or' REJ
  138.  
  139.  call chkres 'You clicked on',URAN,REJ,'!',4,1
  140.  
  141.  call display 'I can change the 'URAN 'and' REJ,
  142.               'requester gadgets',5,1
  143.  
  144.  status 69 set 'Call'       /* Modify gadgets */
  145.  status 70 set 'Now'
  146.  request 'Now Click on Call or Now'
  147.  call chkres 'You clicked on','Call','Now','!',4,4
  148.  
  149.  status 69 set Okay     /* Restere old settings */
  150.  status 70 set Cancel
  151.  
  152.  call display 'If need be, I can get a whole string of text',4,1
  153.  
  154.  getstring 'Enter N E M E S I S'
  155.  call scroll 2,result,2
  156.  
  157.  call wait(2)
  158. return
  159.  
  160. /******************************************************/
  161. /*                                                    */
  162. /*          DOpus window to back - front demo         */
  163. /*                                                    */
  164. /* This function is extreamly simple, just read it.   */
  165. /* if you don't understand it, forget about           */
  166. /* learning ARexx !                                   */
  167. /*                                                    */
  168. /******************************************************/
  169.  
  170. back_front:
  171.  call display 'I can move the DOpus screen to the back',4,1
  172.  
  173.  dopustoback             /* Push DOpus window to the back */
  174.  call wait(3)
  175.  
  176.  dopustofront            /* Bring DOpus window back to the front */
  177.  call wait(1)
  178.  
  179.  call display 'and afterwards, I can bring it back to the front',4,3
  180. return
  181.  
  182. /******************************************************/
  183. /*                                                    */
  184. /*    Function shows the use of the busy pointer      */
  185. /*                                                    */
  186. /*  This function is very simple, nothing out of the  */
  187. /* ordinary.                                          */
  188. /*                                                    */
  189. /******************************************************/
  190.  
  191. busy_demo:
  192.  dopustofront
  193.  
  194.  busy on
  195.  call wait (2)
  196.  
  197.  call display 'Call now to make up for lost time',4,1
  198.  
  199.  call display 'NEMESIS BBS (DIABOLIKA GROUP) 200 megs on-line!',6,0
  200.  
  201.  call display '++39 (0)51 355-315 OR ++39 (0)51 359-718',9,0
  202.  busy off
  203.  
  204.  call wait(2)
  205.  toptext clear_top
  206.  call wait(2)
  207. return
  208.  
  209. /******************************************************/
  210. /*                                                    */
  211. /*    Function clears all files and adds new ones     */
  212. /*                                                    */
  213. /*  This function is a demonstration of how to work   */
  214. /* with adding and removing files in DOpus. The best  */
  215. /* way to describe it is simply to read it through.   */
  216. /* (As most of us have to do !)                       */
  217. /*                                                    */
  218. /******************************************************/
  219.  
  220. file_demo:
  221.  call display 'I can remove all the files in a given window',4,1
  222.  
  223.  status 37
  224.  if result = 1 then swapwindows        /* Switch selected window to 0 */
  225.  
  226.  status 55
  227.  old_buff = result                     /* Get current buffer */
  228.  
  229.  next_buff = old_buff + 1              /* Get next buffer */
  230.  if next_buff = 20 then next_buff = 0
  231.                           /* Highly unlikely, but it's all possible! */
  232.  
  233.  status 55 set next_buff   /* Move to next buffer */
  234.  
  235.  call clear_entries(0)
  236.  
  237.  call display 'Note that I moved on to the next window buffer',6,1
  238.  
  239.  call display 'this means that the original window is still intact.',6,2
  240.  
  241.  call display  'I can switch back to it after I have finished with the next',
  242.                'window buffer.',6,1
  243.  
  244.  status 55 set old_buff
  245.  call wait(1)
  246.  
  247.  call display 'See !',4,1
  248.  
  249.  status 55 set next_buff
  250.  toptext clear_top
  251.  call wait(3)
  252.  
  253.  call display 'Anyway, now to add some files to this window',4,1
  254.  
  255.  do i = 1 to 5
  256.   addfile '"NEMESIS BBS ++39 (0)51 355-315"'i 1000*i '-1' '100' '"No Comment"' 'rwed' 0 1
  257.  end
  258.  call wait(2)
  259.  
  260.  call display 'NOTE: the files were created inside a do end loop',
  261.               'for i = 1 to 5 with :',6,1
  262.  
  263.  call display 'addfile ''"NEMESIS File"''i '1000*i' ''-1'' ''100''',
  264.               '''"No Comment"'' ''rwed'' 0 1',10,1
  265.  
  266.  call display 'DOpus uses the quotes to allow spaces to be included',
  267.               'in names or comments',5,3
  268.  
  269.  call display 'In the same way, directories can be added :',4,1
  270.  
  271.  do i = 1 to 5
  272.   addfile '"For New Stuff Call...         "'i 1000*i '1' '100' '"No comment"' 'rwed' 0 1
  273.  end
  274.  call wait(2)
  275.  
  276.  call display 'Now, I can remove entries (both directories and files)',
  277.               'from the window',5,1
  278.  
  279.  removefile '"NEMESIS BBS ++39 (0)51 355-315"' 1
  280.  call wait(1)
  281.  removefile '"NEMESIS BBS ++39 (0)51 355-315"' 1
  282.  call wait(1)
  283.  removefile '"For New Stuff Call...         "' 1
  284.  call wait(1)
  285.  removefile '"For New Stuff Call...         "' 1
  286.  call wait(3)
  287.  
  288.  call display 'NOTE : Although you can add and remove entries through ARexx',
  289.               'and DOpus,',6,0
  290.  call display 'it really only makes sense to do so when appropriate.',5,1
  291.  
  292.  status 55 set old_buff
  293. return
  294.  
  295. /******************************************************/
  296. /*                                                    */
  297. /*            Function shows configuration            */
  298. /*                                                    */
  299. /*  This function goes through finding out all the    */
  300. /* options set by the user and telling them.          */
  301. /*                                                    */
  302. /******************************************************/
  303.  
  304. config_demo:
  305.  call display 'I can now tell you some of your DOpus configurations',4,1
  306.  
  307.  status 1
  308.  call chkres 'You','have','do not have','workbench to front on',4,1
  309.  status 2
  310.  call chkres 'Interlace','is','is not','on',4,1
  311.  status 3
  312.  call chkres 'File double click','is','is not','on',4,1
  313.  status 4
  314.  call chkres 'You','wish','do not wish','files to be seperated from directories',4,1
  315.  status 5
  316.  call chkres 'You wish files with hidden bit set','to not','to','be displayed',4,1
  317.  status 6
  318.  call chkres 'You have dynamic update','on','off','',4,1
  319.  status 7
  320.  call chkres 'Error checking is','on','off','',4,1
  321.  status 8
  322.  call chkres 'You','wish','do not wish','to be asked before files are deleted',4,1
  323.  status 9
  324.  call chkres 'You','wish','do not wish','to be asked before directories are deleted',4,1
  325.  status 10
  326.  call chkres 'You','want','do not want','file info to be displayed',4,1
  327.  status 11
  328.  call chkres 'Existing files will be replaced','when requested','at all times','',4,1
  329.  status 12
  330.  call chkres 'Icons will','be','not be','created with created directories',4,1
  331.  status 13
  332.  call chkres 'Programs','will','will not','be run asynchronously',4,1
  333.  status 14
  334.  call chkres 'Smart parent/root option is turned','on','off','',4,1
  335.  status 15
  336.  call chkres 'All actions','will','will not','do unto icons',4,1
  337.  status 16
  338.  call display 'Current Help file is :' result,4,1
  339.  
  340.  status 17
  341.  select
  342.   when result = 0 then free_text = 'bytes'
  343.   when result = 1 then free_text = 'KBytes/MBytes'
  344.   when result = 2 then free_text = 'blocks'
  345.   when result = 3 then free_text = 'percentage'
  346.  end
  347.  call display 'Current free disk space is shown as' free_text 'free',4,1
  348.  status 18
  349.  select
  350.   when result = 0 then clock_type = 'has a 24hr clock'
  351.   when result = 1 then clock_type = 'has a 12hr clock'
  352.   when result = 2 then clock_type = 'has no clock'
  353.   when result = 3 then clock_type = 'is hidden'
  354.  end
  355.  call display 'Currently the iconified window' clock_type,4,1
  356.  status 19
  357.  call chkres 'The screen clock is a','12hr','24hr','clock',4,1
  358.  
  359.  /* More to go */
  360.  
  361. return
  362.  
  363. /******************************************************/
  364. /*                                                    */
  365. /*       Function gives the answer ans1 or ans2       */
  366. /*                                                    */
  367. /*  Given the status to check, the program will send  */
  368. /* the given string and then the matching answer for  */
  369. /* a status return value of yes or no.                */
  370. /*                                                    */
  371. /******************************************************/
  372.  
  373. chkres:
  374.  parse arg text1,ans1,ans2,text2,wait1,wait2
  375.  
  376.  select
  377.   when result = 1 then call display ''text1 ans1 text2'',wait1,wait2
  378.   when result = 0 then call display ''text1 ans2 text2'',wait1,wait2
  379.  end
  380. return
  381.  
  382. /******************************************************/
  383. /*                                                    */
  384. /*    Function scrolls text across the top text bar   */
  385. /*                                                    */
  386. /*  This function scrolls text across the top of the  */
  387. /* message bar on the DOpus screen. It is very messy  */
  388. /* but works, and thats all that was intended to do.  */
  389. /*                                                    */
  390. /******************************************************/
  391.  
  392. scroll:
  393.  parse arg start_wait,text,end_wait
  394.  
  395.  text = space(text,1,'A0'X)
  396.  text = copies('A0'X,80) || text || copies('A0'X,80)
  397.  call wait(start_wait)
  398.  
  399.  if length(text) > 80
  400.   then
  401.    do char = 1 to length(text)
  402.     toptext substr(text,char,80,'A0'X)
  403.    end
  404.  call wait(end_wait)
  405. return
  406.  
  407. /******************************************************/
  408. /*                                                    */
  409. /*    Function clears all entries in given window     */
  410. /*                                                    */
  411. /*  This function clears all the entries (directories */
  412. /* and files) in the given DOpus window. The function */
  413. /* should work in all cases, one that didn't work     */
  414. /* when I first wrote it was a file with spaces but   */
  415. /* as DOpus will remove the quotes from quoted files  */
  416. /* I quoted before sending and it works fine now.     */
  417. /*                                                    */
  418. /******************************************************/
  419.  
  420. clear_entries:
  421.  arg window
  422.  
  423.  status 37 set window    /* Set selected window to 0 */
  424.  status 40 window        /* Get number of entries in 0 */
  425.  number = result
  426.  if number >= 0 then
  427.   do i = 1 to number
  428.    getentry 1
  429.    name = result
  430.    removefile '"'name'"' 1
  431.   end
  432. return
  433.  
  434. /******************************************************/
  435. /*                                                    */
  436. /*       Function flashes the given text x times      */
  437. /*                                                    */
  438. /*  This function simply flashes the text given with  */
  439. /* a two second pause between flashes. The function   */
  440. /* uses the wait() procedure below                    */
  441. /*                                                    */
  442. /******************************************************/
  443.  
  444. flash:
  445.  parse arg times,text
  446.  
  447.  do i = 1 to times
  448.   toptext text
  449.   call wait(1)
  450.   toptext clear_top
  451.   call wait(1)
  452.  end
  453. return
  454.  
  455. /******************************************************/
  456. /*                                                    */
  457. /*         Function displays text and pauses          */
  458. /*                                                    */
  459. /* This function will display text in the top message */
  460. /* section on the DOpus screen. The program waits     */
  461. /* a given number of seconds using wait() below and   */
  462. /* then clears the text and waits another given time  */
  463. /* period.                                            */
  464. /*                                                    */
  465. /******************************************************/
  466.  
  467. display:
  468.  parse arg text,wait_1,clear_wait
  469.  
  470.  toptext text
  471.  if wait_1 > 0 then call wait(wait_1)
  472.  toptext clear_top
  473.  if wait_1 > 0 then call wait(clear_wait)
  474. return
  475.  
  476. /******************************************************/
  477. /*                                                    */
  478. /*   Function waits until a given time period passes  */
  479. /*                                                    */
  480. /*  This function simply waits until a given number   */
  481. /* of seconds pass. I tried looking for an easier way */
  482. /* to accomplish the task without busy waiting, but   */
  483. /* alas, I couldn't find support anywhere.            */
  484. /*                                                    */
  485. /******************************************************/
  486.  
  487. wait:
  488.  arg time_wait
  489.  
  490.  time_until = time('S') + time_wait
  491.  do while time(s) < time_until
  492.  end
  493. return
  494.  
  495. /******************************************************/
  496. /*                                                    */
  497. /*                  Error subroutine                  */
  498. /*                                                    */
  499. /*   This function remains to show a simple form of   */
  500. /* error checking, you will get errors while writing  */
  501. /* a script and this (and the following) can make     */
  502. /* life easier !                                      */
  503. /*                                                    */
  504. /******************************************************/
  505.  
  506. error:
  507.  address 'DOpus_rexx'
  508.  toptext '*** ERROR('rc'): line('SIGL')' errortext(rc)
  509. exit
  510.  
  511. /******************************************************/
  512. /*                                                    */
  513. /*               Syntax Error subroutine              */
  514. /*                                                    */
  515. /******************************************************/
  516.  
  517. syntax:
  518.  address 'DOpus_rexx'
  519.  toptext '*** SYNTAX ERROR('rc'): line('sigl')' errortext(rc)
  520. exit
  521.  
  522. /******************************************************/
  523. /*                                                    */
  524. /*                 I/O Error subroutine               */
  525. /*                                                    */
  526. /******************************************************/
  527.  
  528. ioerr:
  529.  address 'DOpus_rexx'
  530.  toptext '*** IOERR('rc'): line('sigl')' errortext(rc)
  531. exit
  532.  
  533. /***************/
  534. /*  The end !  */
  535. /***************/
  536.